#!/usr/bin/perl
#index.cgi
#config the printers

require './printer-lib.pl';

&header($text{'index_title'}, "", "index", 0, 1,undef,undef);

if (!(-d $config{'configdir'})){
	`mkdir -p $config{'configdir'}`;
}
print "<form name=printform action=setprinter.cgi method=post onsubmit='disable_buttons()'>\n";

print "<table width=100% class=mode2><tr>\n";
print "<td  valign=top><table class=mode1 border=0 bordercolor=#000000 cellspacing=0 cellpadding=1 width=100%>\n";
print "<tr class=title1> <td><b>$text{'type'}</b></td> ","<td><b>$text{'place'}</b></td> ","<td><b>$text{'name'}</b></td> </tr>\n";
&printers;
print "</table><p></p>\n";
print "<input type=hidden name=selectone>\n";
print "<input type=hidden name=pagestate value='new'>\n";
print "<td valign=top width=100><table class=mode1 border=0 cellspacing=4 cellpadding=1 width=100%>\n";
print "<tr> <td align=left><input type=submit class=button name=checklp value=$text{'set_title'} onclick='return on_check();'></td></tr>\n";
print "<tr> <td align=center><input type=submit class=button name=cfglp value=$text{'config'} onclick='return on_config();'></td></tr>\n";
print "<tr> <td align=center><input type=submit class=button name=dellp value=$text{'delete'} onclick='return on_delete();'></td></tr>\n";
print "</table>\n";
print "</td></tr></table></form>\n";

print <<EOF;
<script>
function disable_buttons()
{
	document.printform.checklp.disabled = true;
	document.printform.cfglp.disabled = true;
	document.printform.dellp.disabled = true;
}

function on_check()
{
	document.printform.selectone.value='1';
	document.printform.action = 'addprinter.cgi';
}

function on_config()
{
	document.printform.selectone.value='2';
}

function on_delete()
{
	document.printform.selectone.value='3';
}
</script>
EOF

&footer("/",$text{'index'});
1;
